package com.company.service;


import com.company.dao.PhoneDAO;
import com.company.entity.Phone;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class MainService {
    @Autowired
    PhoneDAO phoneDAO;

    public List<Phone> queryUserPhones(int userid){
        return phoneDAO.queryByUserId(userid);
    }

    public void addPhone(String name, String tel, Integer id) {
        Phone p = new Phone();
        p.setName(name);
        p.setTel(tel);
        p.setUserid(id);
        phoneDAO.add(p);
    }

    public void delPhone(int pid, Integer id) {
        phoneDAO.del(pid);
    }

    public Phone queryPhone(int pid, Integer userid) {
        return phoneDAO.queryPhone(pid);
    }

    public void editPhone(Phone p) {
        phoneDAO.editPhone(p);
    }
}
